package lib.Common;

import java.util.Random;

public class UserId {
	/**
	 * Class to generate user Id's and timestamp
	 */
	public static String createId(){
		String timestamp = String.valueOf(getTimestamp());
		String userId = "";
		for(int i=0; i<timestamp.length(); i++)
		{
			userId=userId+randomChar()+timestamp.charAt(i);
		}
		userId=userId+randomChar();
		return userId;
	}

	public static long getTimestamp(){
		return System.currentTimeMillis();
	}
	
	public static boolean isNewer(long i1, long i2){
		if(i1>=i2){
			return true;
		}else{
			return false;
		}
	}
	
	public static char randomChar(){
		String base = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		Random r = new Random();
		char c = base.charAt(r.nextInt(base.length()));
		return c;
	}
}
